Eliminate use of strptime in cst.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 20 Jan 2015 02:39:51 +0000 (02:39 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 20 Jan 2015 02:39:51 +0000 (02:39 +0000)
gpsbabel/cst.cc
gpsbabel/parse.cc

index e307db2a7b0ea2262a4dae646fa184303862f70f..04d4b3cc8ba4344e09f1c487e39266617864e2bb 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "defs.h"
 #include "cet_util.h"
-#include "strptime.h"
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -248,7 +247,6 @@ cst_data_read(void)
       } else {
         int interp, i;
         char name[256];
-        char* pow;
 
         if (data_lines < 0) {
           if ((2 != sscanf(cin, "%d %128s", &i, name)) ||
@@ -284,14 +282,13 @@ cst_data_read(void)
           wpt->shortname = QString::fromLatin1(((char*)&name) + 5);
         }
 
-        pow = strrchr(cin, '^');
-        if (pow != NULL) {
-          struct tm tm;
-
-          pow = lrtrim(++pow);
-          strptime(pow, "%Y %m %d %H:%M:%S", &tm);
-
-          wpt->SetCreationTime(mkgmtime(&tm));
+        QString time_string(cin);
+        int caret = time_string.indexOf('^');
+        if (caret > -1) {
+          QString dts = time_string.mid(caret + 1).trimmed();
+          QDateTime dt = QDateTime::fromString(dts, "yyyy MM dd hh:mm:ss");
+          dt.setTimeSpec(Qt::UTC);
+          wpt->SetCreationTime(dt);
         }
         wpt->latitude /= 100000.0;
         wpt->longitude /= 100000.0;
index 9003a9c869293c83d93f19a4112b597cbc5b2a42..6540b94b530b28b98edfbbc9c02d33a4cc18aa16 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "defs.h"
 #include "jeeps/gpsmath.h"
-#include "strptime.h"
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h> //strtod